<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:insert="~{include :: header('修改配置信息')}" />
    <style>
        .form-group span{
            color: red;
        }
    </style>
</head>
<body class="hold-transition">
<div class="container-fluid mt-2 mb-2">
    <form class="form-horizontal m" id="form-profile-edit" th:object="${websiteProfile}">
        <input id="modelType"  th:value="${modelType}" type="hidden"/>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">appId</label>
            <div class="col-sm-6">
                <input id="appId" name="appId" class="form-control" type="text" th:value="*{get('appId')}">
                <span>（微信公众平台appId）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">appSecret</label>
            <div class="col-sm-6">
                <input id="appSecret" name="appSecret" class="form-control" type="text" th:value="*{get('appSecret')}">
                <span>（微信公众平台AppSecret）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">mchId</label>
            <div class="col-sm-6">
                <input id="mchId" name="mchId" class="form-control" type="text" th:value="*{get('mchId')}">
                <span>（微信公众平台所对应的微信支付商户号）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">apiKey</label>
            <div class="col-sm-6">
                <input id="apiKey" name="apiKey" class="form-control" type="text" th:value="*{get('apiKey')}">
                <span>（微信公众平台所对应的微信支付商户号中的apiKey）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">serialNo</label>
            <div class="col-sm-10">
                <input id="serialNo" name="serialNo" class="form-control" type="text" th:value="*{get('serialNo')}">
                <span>（微信公众平台所对应微信支付商户号证书系列号）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">privateKey</label>
            <div class="col-sm-10">
                <textarea name="privateKey" class="form-control" style="height: 100px;" type="text" th:text="*{get('privateKey')}"></textarea>
                <span>（微信公众平台所对应微信支付商户号证书私钥/密钥）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">notifyUrl</label>
            <div class="col-sm-10">
                <input name="notifyUrl" class="form-control" type="text" th:value="*{get('notifyUrl')}">
                <span>微信支付成功后的回调地址（输入带域名的完整地址）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">appName</label>
            <div class="col-sm-6">
                <input id="appName" name="appName" class="form-control" type="text" th:value="*{get('appName')}">
                <span>（H5支付应用名称appName）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2 col-form-label text-sm-right">appUrl</label>
            <div class="col-sm-6">
                <input id="appUrl" name="appUrl" class="form-control" type="text" th:value="*{get('appUrl')}">
                <span>（H5支付应用网址appUrl）</span>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-sm-2"></label>
            <div class="col-sm-offset-2 col-sm-6">
                <button type="button" class="btn btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
                <button type="button" class="btn btn-danger" onclick="window.parent.layer.closeAll()"><i class="fa fa-reply-all"></i>关 闭 </button>
            </div>
        </div>
    </form>
</div>
<th:block th:insert="~{include :: footer}" />
<script type="text/javascript">

    var prefix = "/profile";

    function submitHandler() {
        var modelType = $("#modelType").val();
        if ($.validate.form()) {
            var baseInfo = {};
            var formArray = $("#form-profile-edit").serializeArray();
            $.each(formArray, function (i, item) {
                baseInfo[item.name] = item.value;
            });
            var description = JSON.stringify(baseInfo);
            $.post(prefix + "/save.json", {"type": modelType, "description": description}, function (json) {
                console.log(json)
                if (json.code === 0) {
                    window.parent.layer.closeAll();
                }
            })
        }
    }

</script>
</body>
</html>